package com.acme.bankapp.domain.bank;

import java.util.Arrays;

import com.acme.bankapp.domain.bank.account.Account;

public class Client {
	public final static int MAX_ACCOUNT = 3;
	
	private int countAccounts = 0;
	
	public int getCountAccounts() {
		return countAccounts;
	}
	
	private Account[] accounts;
	
	public void addAccount(Account account) throws Exception {
		if (countAccounts == MAX_ACCOUNT)
			throw new Exception("Client already contains the maximum number of accounts");
		accounts[countAccounts] = account;
		countAccounts++;
	}
	
	private String name;
	
	private Gender gender;
	
	/**
	 * 
	 * @param name name of client
	 * @param isMan is man - true, false - woman
	 */
	public Client(String name, Gender gender) {
		this.name = name;
		this.gender = gender;
		accounts = new Account[MAX_ACCOUNT];
	}
	
	public Account[] getAccounts() {
		return Arrays.copyOf(accounts, countAccounts);
	}
	
	public String getClientSalution() {
		return gender.getAppeal() + " " + name;
	}
}